Working with Summary Fields

How to change summary field kind

This example populates a combo box with the various summary field kind options and then sets a summary field to the kind selected. This code assumes that you have elsewhere declared a variable cr for your report.

Private Sub Form_Load()
Dim i As Integer

Populate the combo box.

cmbSummaryType.AddItem "crSTSum"
cmbSummaryType.AddItem "crSTAverage"
cmbSummaryType.AddItem "crSTSampleVariance"
cmbSummaryType.AddItem "crSTSampleStandardDeviation"
cmbSummaryType.AddItem "crSTMaximum"
cmbSummaryType.AddItem "crSTMinimum"
cmbSummaryType.AddItem "crSTCount"
cmbSummaryType.AddItem "crSTPopVariance"
cmbSummaryType.AddItem "crSTPopStandardDeviation"
cmbSummaryType.AddItem "crSTDistinctCount"

Get the SummaryFields collection.

Set CRXSummaryFieldDefinitions = CRXReport.SummaryFields
txtCount = CrystalSummaryFieldDefinitions.Count

Cycle through the collection.

For i = 1 To CRXSummaryFieldDefinitions.Count
    Set CRXSummaryFieldDefinition =
CRXSummaryFieldDefinitions.Item(i) lstFieldDefinition.AddItem CRXSummaryFieldDefinition.Name Next i End Sub

Change the summary field kind.

Private Sub lstFieldDefinition_Click()
     Set CRXSummaryFieldDefinition = 
CRXSummaryFieldDefinitions.Item(lstFieldDefinition.ListIndex + 1)
     With CRXSummaryFieldDefinition
        cmbSummaryType.Text = cmbSummaryType.List(.SummaryType)
        txtKind = .Kind
        txtName = .Name
        txtNumberofBytes = .NumberOfBytes
        txtValue = OnFormat
        txtValueType = .ValueType 
      End With
End Sub


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com